package com.exam.bean;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * 考试信息实体 2012-12-27
 * 
 * @author MuLing
 * 
 */
@Entity
@Table(name = "tb_exam_Info")
public class ExamInfo implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	// 指定为主键
	@GeneratedValue(strategy = GenerationType.AUTO)
	// 主键类型为自增长
	private Integer id;// 主键id

	@OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
	@JoinColumns(@JoinColumn(name = "p_id", referencedColumnName = "id"))
	private Paper paper;// 本次考试对应的试卷，来自试卷表

	@OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
	@JoinColumns(@JoinColumn(name = "u_id", referencedColumnName = "id"))
	private User user;// 本次考试对应的用户，来自用户表

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "u_startDateTime")
	private Date startDateTime;// 用户考试开始时间

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "u_endDateTime")
	private Date endDateTime;// 用户考试结束时间

	@Column(name = "u_score")
	private int score;// 用户试卷得分

	@Column(name = "u_duration")
	private int duration;// 用户考试时长，分钟计时

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * @return the id
	 */
	public Integer getId() {
		return id;
	}

	/**
	 * @param startDateTime
	 *            the startDateTime to set
	 */
	public void setStartDateTime(Date startDateTime) {
		this.startDateTime = startDateTime;
	}

	/**
	 * @return the startDateTime
	 */
	public Date getStartDateTime() {
		return startDateTime;
	}

	/**
	 * @param endDateTime
	 *            the endDateTime to set
	 */
	public void setEndDateTime(Date endDateTime) {
		this.endDateTime = endDateTime;
	}

	/**
	 * @return the endDateTime
	 */
	public Date getEndDateTime() {
		return endDateTime;
	}

	/**
	 * @param score
	 *            the score to set
	 */
	public void setScore(int score) {
		this.score = score;
	}

	/**
	 * @return the score
	 */
	public int getScore() {
		return score;
	}

	/**
	 * @param duration
	 *            the duration to set
	 */
	public void setDuration(int duration) {
		this.duration = duration;
	}

	/**
	 * @return the duration
	 */
	public int getDuration() {
		return duration;
	}

	/**
	 * @param paper
	 *            the paper to set
	 */
	public void setPaper(Paper paper) {
		this.paper = paper;
	}

	/**
	 * @return the paper
	 */
	public Paper getPaper() {
		return paper;
	}

	/**
	 * @param user
	 *            the user to set
	 */
	public void setUser(User user) {
		this.user = user;
	}

	/**
	 * @return the user
	 */
	public User getUser() {
		return user;
	}

}
